package presentationTier.actions;

import presentationTier.dialogs.ChangeMediumDialog;
import businessTier.IMovieFacade;
import businessTier.MovieFacade;
import core.Medium;
import core.MovieException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


/**
 *
 * @author vojta
 */
public class ChangeMediumRemoveAction implements ActionListener{

    ChangeMediumDialog dialog;

    public ChangeMediumRemoveAction(ChangeMediumDialog aThis) {
        dialog = aThis;
    }

    public void actionPerformed(ActionEvent e) {
        Medium medium = (Medium) dialog.jComboBox1.getSelectedItem();
        
        try {
            IMovieFacade mf = MovieFacade.getInstance();
            mf.removeMedium(medium);
            mf.close();

            ChangeMediumDialog.main(null);
            dialog.dispose();
            
        } catch (MovieException ex) {
            ex.printStackTrace();
        }
    }
}
